@echo off
title 📦 一键打包PWA文件
color 0A

echo.
echo  ╔══════════════════════════════════════════════════════════════╗
echo  ║                  📦 PWA文件打包工具                          ║
echo  ║                                                             ║
echo  ║  💡 将PWA相关文件打包，方便手动上传到Gitee                 ║
echo  ╚══════════════════════════════════════════════════════════════╝
echo.

:: 设置变量
set "SOURCE_DIR=C:\Users\Administrator\Documents\trae_projects\lt00001\magazine"
set "BACKUP_DIR=%USERPROFILE%\Desktop\PWA_上传包"
set "TIMESTAMP=%date:~0,4%%date:~5,2%%date:~8,2%_%time:~0,2%%time:~3,2%%time:~6,2%"
set "TIMESTAMP=%TIMESTAMP: =0%"

echo 📁 正在创建打包目录...
if not exist "%BACKUP_DIR%" mkdir "%BACKUP_DIR%"
if not exist "%BACKUP_DIR%\%TIMESTAMP%" mkdir "%BACKUP_DIR%\%TIMESTAMP%"

echo 📋 正在复制PWA核心文件...
:: 复制主要PWA文件
copy "%SOURCE_DIR%\手机PWA直接打开版.html" "%BACKUP_DIR%\%TIMESTAMP%\" >nul
copy "%SOURCE_DIR%\PWA快速使用指南.md" "%BACKUP_DIR%\%TIMESTAMP%\" >nul
copy "%SOURCE_DIR%\手动上传Gitee指南.md" "%BACKUP_DIR%\%TIMESTAMP%\" >nul
copy "%SOURCE_DIR%\手机使用说明.md" "%BACKUP_DIR%\%TIMESTAMP%\" >nul
copy "%SOURCE_DIR%\service-worker.js" "%BACKUP_DIR%\%TIMESTAMP%\" >nul
copy "%SOURCE_DIR%\manifest.json" "%BACKUP_DIR%\%TIMESTAMP%\" >nul
copy "%SOURCE_DIR%\一键手机版.bat" "%BACKUP_DIR%\%TIMESTAMP%\" >nul

echo 📱 正在复制移动端文件...
:: 复制移动端相关文件
copy "%SOURCE_DIR%\mobile-pwa.html" "%BACKUP_DIR%\%TIMESTAMP%\" >nul 2>nul
copy "%SOURCE_DIR%\static\manifest.json" "%BACKUP_DIR%\%TIMESTAMP%\" >nul 2>nul

echo 📖 正在复制文档文件...
:: 复制文档文件
copy "%SOURCE_DIR%\使用指南.md" "%BACKUP_DIR%\%TIMESTAMP%\" >nul 2>nul
copy "%SOURCE_DIR%\README.md" "%BACKUP_DIR%\%TIMESTAMP%\" >nul 2>nul

echo 🎨 正在复制样式文件...
:: 复制CSS和JS文件（如果存在）
if exist "%SOURCE_DIR%\static\css" (
    xcopy "%SOURCE_DIR%\static\css" "%BACKUP_DIR%\%TIMESTAMP%\css\" /E /I /Y >nul 2>nul
)
if exist "%SOURCE_DIR%\static\js" (
    xcopy "%SOURCE_DIR%\static\js" "%BACKUP_DIR%\%TIMESTAMP%\js\" /E /I /Y >nul 2>nul
)

echo ✅ 打包完成！
echo.
echo 📂 文件已打包到：
echo   %BACKUP_DIR%\%TIMESTAMP%
echo.
echo 📋 打包的文件列表：
dir "%BACKUP_DIR%\%TIMESTAMP%" /B
echo.
echo 🚀 下一步操作：
echo 1. 打开桌面上的 PWA_上传包 文件夹
echo 2. 进入最新的时间戳文件夹
echo 3. 将所有文件上传到Gitee仓库
echo.
echo 💡 上传方法：
echo - 方法1：访问 https://gitee.com/k1565566/magazine 直接拖拽上传
echo - 方法2：使用Gitee Web界面的文件上传功能
echo - 方法3：通过Git命令推送（需要Git环境）
echo.
echo 📱 手机使用：
echo 1. 将"手机PWA直接打开版.html"发送到手机
echo 2. 在手机浏览器中打开
echo 3. 添加到主屏幕完成安装
echo.
echo 🔄 按任意键打开打包目录...
pause >nul

:: 打开打包目录
explorer "%BACKUP_DIR%\%TIMESTAMP%"
echo.
echo ✅ 已打开打包目录，请按照上述步骤上传到Gitee！
echo.
pause